package com.heking.commonlib;

import androidx.appcompat.app.AppCompatActivity;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.os.Bundle;
import android.widget.ImageView;

import com.zhoug.common.utils.BitmapUtils;
import com.zhoug.common.utils.LogUtils;
import com.zhoug.common.utils.ResourceUtils;

/**
 * {@link com.zhoug.common.utils.BitmapUtils}
 */
public class BitmapUtilsActivity extends AppCompatActivity {
    private static final String TAG = ">>>BitmapUtilsActivity";
    private ImageView mImage1;
    private ImageView mImage2;
    private ImageView mImage3;
    private ImageView mImage4;
    private ImageView mImage5;
    private ImageView mImage6;
    private ImageView mImage7;
    private ImageView mImage8;
    private ImageView mImage9;
    private ImageView mImage10;
    private ImageView mImage11;
    private ImageView mImage0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_bitmap_utils);
        findViews();


        Bitmap bitmap = BitmapUtils.decodeResource(getResources(),R.drawable.zxc,500,300,Bitmap.Config.ARGB_8888);
        LogUtils.d(TAG, "onCreate:"+bitmap.getByteCount()/1024);
        mImage1.setImageBitmap(BitmapUtils.toRoundBitmap(bitmap));
        mImage2.setImageBitmap(BitmapUtils.toRoundBitmap(bitmap,0.6f,null));
        int corners = ResourceUtils.dpTopx(20);
        mImage0.setImageBitmap(BitmapUtils.toCornersBitmap(bitmap,0,false,false,false,false));
        mImage3.setImageBitmap(BitmapUtils.toCornersBitmap(bitmap,corners,true,true,true,true));
        mImage4.setImageBitmap(BitmapUtils.toCornersBitmap(bitmap,corners,true,true,false,false));
        mImage5.setImageBitmap(BitmapUtils.toCornersBitmap(bitmap,2000,true,true,true,true));

        mImage6.setImageBitmap(BitmapUtils.createBitmap(Color.RED,500,300, Bitmap.Config.RGB_565,0,false,false,false,false));
        mImage7.setImageBitmap(BitmapUtils.createBitmap(Color.GREEN,500,300,Bitmap.Config.ARGB_4444,80,true,true,true,true));
        mImage8.setImageBitmap(BitmapUtils.createBitmap(Color.MAGENTA,500,500,null,50,true,false,true,false));
        mImage9.setImageBitmap(BitmapUtils.createBitmap(Color.BLUE,500,500,null,500,true,true,true,true));
        mImage10.setImageBitmap(BitmapUtils.createBitmap(Color.RED,500,300, Bitmap.Config.RGB_565));
        mImage11.setImageBitmap(BitmapUtils.createRoundBitmap(Color.parseColor("#ff00ff"),300, Bitmap.Config.ARGB_4444));

    }

    private void findViews() {
        mImage1 = findViewById(R.id.image1);
        mImage2 = findViewById(R.id.image2);
        mImage3 = findViewById(R.id.image3);
        mImage4 = findViewById(R.id.image4);
        mImage5 = findViewById(R.id.image5);
        mImage6 = findViewById(R.id.image6);
        mImage7 = findViewById(R.id.image7);
        mImage8 = findViewById(R.id.image8);
        mImage9 = findViewById(R.id.image9);
        mImage10 = findViewById(R.id.image10);
        mImage11 = findViewById(R.id.image11);
        mImage0 = findViewById(R.id.image0);
    }
}